<style lang="less">
@import '../../../styles/common.less';
</style>

<template>
    <Card style="height:900px">
        <Card style="height:180px">
            <div style="margin-top:30px">
                <div>
                    <div style="margin-left: 10px;float:left">日期：</div>
                    <Col style="float:left;margin-left: 20px;">
                    <DatePicker v-model="trialCondition.applyBeginDate" type="date" style="width: 150px" name="pushBeginDate"></DatePicker>
                    </Col>
                    <Col style="margin-left: 20px;float:left"> 至
                    </Col>
                    <Col style="margin-left: 20px;float:left">
                    <DatePicker v-model="trialCondition.applyEndDate" type="date" placement="bottom-end" style="width: 150px" name="pushEndDate"></DatePicker>
                    </Col>
                </div>
                <div style="float:left;margin-left: 13px;">
                    <div style="float:left">状态：</div>
                    <div style="margin-left: 20px;float:left">
                        <Select v-model="trialCondition.pushStatus" class="v-select-wrapper" style="width:150px" name="pushStatus">
                            <Option v-for="item in statusList" :value="item.key" :key="item.key">{{ item.label }}</Option>
                        </Select>
                    </div>
                </div>
                <div style="float:left;margin-left: 13px;">
                    <Button type="primary" @click="listQuery" style="margin-top:-5px;">查询</Button>
                    <Upload ref="upload" :on-success="uploadSuccess" :on-error="uploadFail" :on-progress="uploalDealing" :loading="loadingStatus" type="drag" :action="uploadUrl" :show-upload-list="false" name="file" style="margin-left: 78px;margin-top: -45px;">
                        <Button type="primary">上传</Button>
                    </Upload>
                </div>

            </div>
        </Card>
        <Card>
            <div>
                <Table border :columns="orderColumns" :data="orderData" style="width: 100%;" @on-selection-change="handleRowChange" ref="selection"></Table>
            </div>
            <div style="text-align: center;margin-top: 36px;">
                <Page :total="trialCondition.total" :current="trialCondition.pageNum" :page-size="trialCondition.pageSize" size="small" show-elevator show-sizer show-total @on-change="pageChange" @on-page-size-change="sizeChange"></Page>
            </div>
        </Card>
    </Card>
</template>

<script>
export default {
  name: 'mutative-router',
  data () {
    return {
      uploadUrl: this.$appContext.marvels_core_approve + 'approve/loanApplication/service/applyLoanUpload',
      trialCondition: {
        pushStatus: '',
        applyBeginDate: '',
        applyEndDate: '',
        pageNum: 1,
        pageSize: 10,
        total: 0,
        id: ''
      },
      orderColumns: [
        {
          type: 'selection',
          width: 60,
          align: 'center'
        },
        {
          type: 'index',
          title: '序号',
          width: 60
        },
        {
          title: '日期',
          key: 'applyDate',
          align: 'center',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h('span', vm.$util.loanModularFormatTime(params.row.applyDate))
            ])
          }
        },
        {
          title: '推送文件',
          key: 'pushFileName',
          align: 'center',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h('span', vm.$util.loanModularFormatTime(params.row.customerLiquidationTime))
            ])
          }
        },
        {
          title: '上传时间',
          key: 'uploadDate',
          align: 'center',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h('span', vm.$util.loanModularFormatTime(params.row.uploadDate))
            ])
          }
        },
        {
          title: '推送时间',
          key: 'pushDate',
          align: 'center',
          render: (h, params) => {
            var vm = this
            return h('div', [
              h('span', vm.$util.loanModularFormatTime(params.row.pushDate))
            ])
          }
        },
        {
          title: '状态',
          key: 'pushStatus',
          align: 'center'
        },
        {
          title: '操作',
          align: 'center',
          render: (h, params) => {
            if (params.row.status === '0') {
              return h('div', [
                h('span', {
                  style: {
                    'color': '#20a0ff',
                    'cursor': 'pointer'
                  },
                  on: {
                    click: () => {

                    }
                  }
                }, '推送'),
                h('span', {
                  style: {
                    'color': '#20a0ff',
                    'cursor': 'pointer',
                    'margin-left': '10px'
                  },
                  on: {
                    click: () => {

                    }
                  }
                }, '删除')
              ])
            }
          }
        }
      ],
      orderData: [],
      statusList: [
        {
          'key': '',
          'label': '请选择'
        },
        {
          'key': '1',
          'label': '未推送'
        },
        {
          'key': '0',
          'label': '成功'
        },
        {
          'key': '2',
          'label': '失败'
        }
      ],
      productList: []
    }
  },
  computed: {
    avatorImage () {
      return localStorage.avatorImgPath
    }
  },

  created () {
    // 初始化当前页面请求对象实例
    this.$ajax = this.$util.ajax()
    this.listQuery()
  },

  methods: {
    pageChange: function (pageNum) {
      var vm = this
      vm.trialCondition.pageNum = pageNum
      vm.listQuery()
    },
    sizeChange: function (pageLength) {
      var vm = this
      vm.trialCondition.pageSize = pageLength
      vm.listQuery()
    },
    listQuery () {
      var vm = this
      this.$ajax.post(this.$appContext.marvels_core_financial + 'financial/fund/bhLiquidation/service/fundTransferList', vm.trialCondition).then(re => {
        var data = re.data
        vm.orderData = data.data.list
        vm.trialCondition.total = data.data.total
      }).catch(er => {

      })
    },
    uploadSuccess (response) {
      this.loadingStatus = false
      var code = response.code
      var message = response.message
      if (code !== 'success') {
        this.$Message.warning(message)
      }
    },
    uploadFail (error) {
      this.loadingStatus = false
      this.$Message.warning(error.message)
    },
    uploalDealing () {
      this.loadingStatus = true
    }

  }
}
</script>
